/**
 * @description parse elem html
 * @author snake
 */

import { Descendant, Text } from 'slate'
import { IDomEditor, SlateDescendant, SlateElement } from '@wangeditor/editor'

/**
 * 解析新元素 HTML 到编辑器
 * @param {*} elem 
 * @param {*} children 
 * @param {*} editor 
 * @returns 
 */
function parsePlaceholderHtml(elem, children, editor) {
  const value = elem.getAttribute('data-customAdd') || ''
  const string = elem.innerText

  const myResume = {
    type: 'placeholder',
    string: string || '',
    placeholder: value || '',
    children: [{ text: '' }]
  }

  return myResume
}

const conf = {
  selector: 'span[data-w-e-type="placeholder"]', // CSS 选择器，匹配特定的 HTML 标签
  parseElemHtml: parsePlaceholderHtml
}

export default conf
